package com.happyrecyclingstation.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.happyrecyclingstation.dto.CompanyQueryDto;
import com.happyrecyclingstation.entity.Company;
import com.happyrecyclingstation.mapper.CompanyMapper;
import com.happyrecyclingstation.service.CompanyService;
import com.happyrecyclingstation.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CompanyServiceImpl implements CompanyService {
    @Autowired
    private CompanyMapper companyMapper;
    @Override
    public PageResult<Company> getAllCompanies(CompanyQueryDto companyQueryDto) {
        PageHelper.startPage(companyQueryDto.getCurrentPage(), companyQueryDto.getPageSize());
        Page<Company> page = companyMapper.getAllCompanies(companyQueryDto);
        return new PageResult<>(page.getTotal(), page.getResult());
    }
}
